package com.mks.demo;

import com.mks.demo.mqtt.MqttSender;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Spring
 */
@SpringBootApplication
@MapperScan(basePackages = "com.mks.demo.dao")
@RestController
public class DemoApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DemoApplication.class);
    }

    @Autowired
    private MqttSender mqttSender;

    @RequestMapping("send")
    public String sendData() {
        mqttSender.sendData("/wk/test", 0, "test".getBytes());
        return "mqtt send test";
    }

}
